package dto

import (
	"tuowei.com/app/api/models"
	common "tuowei.com/common/models"
)

type WxLoginReq struct {
	OpenId    string `json:"openId" binding:"required"`
	NickName  string `json:"nickName"`
	Gender    int    `json:"gender"`
	UnionId   string `json:"unionId" binding:"required"`
	AvatarUrl string `json:"avatarUrl"`
	Province  string `json:"province"`
	City      string `json:"city"`
	Country   string `json:"country"`
}

func (wr *WxLoginReq) Generate(wx *models.SysWxStudent) {
	wx.Openid = wr.OpenId
	wx.Nickname = wr.NickName
	wx.Sex = wr.Gender
	wx.UnionId = wr.UnionId
	wx.Avatar = wr.AvatarUrl
	wx.Province = wr.Province
	wx.City = wr.City
	wx.Country = wr.Country
}

type SysWxStudentInsertReq struct {
	common.Model
	StudentId int      `json:"student_id" comment:"关联学员ID"`
	Openid    string   `json:"openid" comment:"微信OPENID"`
	Nickname  string   `json:"nickname" comment:"微信昵称"`
	Sex       int      `json:"sex" comment:"性别"`
	Province  string   `json:"province" comment:"微信获取的省份"`
	City      string   `json:"city" comment:"微信获取的城市"`
	Country   string   `json:"country" comment:"微信获取的地区"`
	Avatar    string   `json:"avatar" comment:"微信获取的头像"`
	Privilege []string `json:"privilege" comment:"用户特权信息，json 数组，如微信沃卡用户为（chinaunicom）"`
	UnionId   string   `json:"union_id" comment:"用户统一标识。针对一个微信开放平台帐号下的应用，同一用户的 unionid 是唯一的。"`
	common.ModelTime
}

func (s SysWxStudentInsertReq) Generate(student *models.SysWxStudent) {
	student.Openid = s.Openid
	student.Nickname = s.Nickname
	student.Province = s.Province
	student.City = s.City
	student.Country = s.Country
	student.Avatar = s.Avatar
	student.Privilege = s.Privilege
	student.UnionId = s.UnionId
}

func (s *SysWxStudentInsertReq) GetId() interface{} {
	return s.Id
}

type SysWxStudentUpdateReq struct {
	common.Model
	StudentId int      `json:"student_id" comment:"关联学员ID"`
	Openid    string   `json:"openid" comment:"微信OPENID"`
	Nickname  string   `json:"nickname" comment:"微信昵称"`
	Sex       int      `json:"sex" comment:"性别"`
	Province  string   `json:"province" comment:"微信获取的省份"`
	City      string   `json:"city" comment:"微信获取的城市"`
	Country   string   `json:"country" comment:"微信获取的地区"`
	Avatar    string   `json:"avatar" comment:"微信获取的头像"`
	Privilege []string `json:"privilege" comment:"用户特权信息，json 数组，如微信沃卡用户为（chinaunicom）"`
	UnionId   string   `json:"union_id" comment:"用户统一标识。针对一个微信开放平台帐号下的应用，同一用户的 unionid 是唯一的。"`
	common.ModelTime
}

func (s SysWxStudentUpdateReq) GetId() interface{} {
	return s.Id
}

func (s SysWxStudentUpdateReq) Generate(student *models.SysWxStudent) {
	if s.Id != 0 {
		student.Id = s.Id
	}
	student.Openid = s.Openid
	student.Nickname = s.Nickname
	student.Province = s.Province
	student.City = s.City
	student.Country = s.Country
	student.Avatar = s.Avatar
	student.Privilege = s.Privilege
	student.UnionId = s.UnionId
}
